Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:46:28+00:00 2026-05-25T20:46:28+00:00

I want to to write np.double to formatted file: import numpy as np a=’12

  • 0

I want to to write np.double to formatted file:

import numpy as np
a='12 45 87 34 65';
s=np.double(a.split())
fid=open('qqq.txt','wt')
fid.write('%5.1f %5.1f %5.1f %5.1f %5.1f ' %(s[0],s[1],s[2],s[3],s[4]))
fid.close()

Can this “write” row be written in a shorter way?

fid.write('%5.1f %5.1f %5.1f %5.1f %5.1f ' %(s[0],s[1],s[2],s[3],s[4]))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:46:28+00:00Added an answer on May 25, 2026 at 8:46 pm

    One way is this

    In [48]: ''.join('%5.1f ' % n for n in s)
    Out[48]: ' 12.0  45.0  87.0  34.0  65.0 '
    

    Another way is

    In [49]: ('%5.1f ' * len(s)) % tuple(s)
    Out[49]: ' 12.0  45.0  87.0  34.0  65.0 '
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a JAR file that makes use of the javax servlet
I want to write to a file in the windows temp directory. I know
I want to write a vb or bat script that goes through a file
Is there a way I can write text to a file from a certain
I want to send the double quote character to my CreateProcess function. How can
I want to write a little Linux Kernel Module that can show me the
I have this structure which I want to write to a file: typedef struct
I want to write something like =HYPERLINK(http://example.com; Example) to a comma-separated CSV file, but
I want to write a method which can take an arbitrary array of a
I have a predetermined amount of one-dimensional double arrays and want to write each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.