Python Forum
convert non-string with explicit base
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert non-string with explicit base
#4
Hi Craig,
Thanks for explain the code.
It work now, i just add integer to it.
line = int+2

HI I have another question would like to ask
How do i add a for loop and print each line from 1 to 10
with open('data.txt') as f,open('data_out.txt', 'w') as f_out:
f_out.write(('===\t=========== \t =========== \t =========== \n').expandtabs(15))
    for line in f:
		#the line variable is set to a string
        line = line.strip()
	f_out.write('{}'.format(line))
right now it will print like this :

1234567890 1234567891 1234567892
i wants to print like this

1 1234567890 1234567891 1234567892
2 1234567890 1234567891 1234567892
.............
10 1234567890 1234567891 1234567892


i just wants to add a range from 1 to 10, but i have no idea where to put the loop.

Thanks
Reply


Messages In This Thread
RE: convert non-string with explicit base - by jacklee26 - Nov-02-2018, 05:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert string to float in list jacklee26 6 1,962 Feb-13-2023, 01:14 AM
Last Post: jacklee26
Thumbs Up Convert an Interger into any base !? [Solved] SpongeB0B 8 1,452 Jan-16-2023, 10:24 AM
Last Post: SpongeB0B
  how to convert tuple value into string mg24 2 2,399 Oct-06-2022, 08:13 AM
Last Post: DeaD_EyE
  Convert string to float problem vasik006 8 3,456 Jun-03-2022, 06:41 PM
Last Post: deanhystad
  is there any tool to convert negative base to int? Skaperen 7 2,446 May-27-2022, 07:30 AM
Last Post: Gribouillis
  Convert a string to a function mikepy 8 2,590 May-13-2022, 07:28 PM
Last Post: mikepy
Question How to convert string to variable? chatguy 5 2,499 Apr-12-2022, 08:31 PM
Last Post: buran
  Convert string to int Frankduc 8 2,527 Feb-13-2022, 04:50 PM
Last Post: menator01
  Convert string to path using Python 2.7 tester_V 10 6,544 Nov-20-2021, 02:20 PM
Last Post: snippsat
  Convert each element of a list to a string for processing tester_V 6 5,397 Jun-16-2021, 02:11 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020