Thread: File i/o problem in python !!!!
i writing code in python 3.2 checking , writing (to text file) dynamic ip ,
here code:, output file "iplist" give data :code:#!/usr/bin/python3.2 import urllib.request raw = urllib.request.urlopen('http://automation.whatismyip.com/n09230945.asp') finaldata=str(raw.read()) outputfile=open("iplist","a") outputfile.write(finaldata + "\n") print("finish!!!"), question why "b" before ip ? , how rid of ?code:b'currentip' b'currentip'
first, there reason why want use python? looks more job shell script.
if want to...
raw.read() returns bytes object, list of integers, each being ascii code of corresponding character in input.code:finaldata = "" in raw.read(): finaldata = finaldata + chr(i)
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk File i/o problem in python !!!!
Ubuntu
Comments
Post a Comment