| |

VerySource

 Forgot password?
 Register
Search
View: 666|Reply: 1

How can I align strings written to a text file

[Copy link]

4

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-1-22 13:40:01
| Show all posts |Read mode
Dear heroes, younger brothers have difficulties, please advise
I now want to write some output data to a text file and align it
example:
database (table name) name (field) zhao (value)
                  age (field) 16 (value)
                  sex (field) man (value)
...
Thank you all
Please use vc
Reply

Use magic Report

0

Threads

45

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-2-6 11:45:01
| Show all posts
Get the length of each table name, take the longest one as the offset, and set the offset at the beginning, that is, the * mark below, so that n, a, and s are aligned

database (table name) name (field) zhao (value)
****************** age (field) 16 (value)
****************** sex (field) man (value)

anotherdatabase name zhang
                  age ...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list