From 974757e392466403a65c683d86b1bf61d33aeaf4 Mon Sep 17 00:00:00 2001 From: yuhuashangedward Date: Wed, 14 Nov 2018 14:27:07 +0800 Subject: [PATCH] modify in python3 --- codes/105.py | 4 +++- codes/217.py | 4 ++-- codes/220-2.py | 10 +++++----- codes/220.py | 10 +++++----- codes/221.py | 6 +++--- codes/225.py | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/codes/105.py b/codes/105.py index fd7a36f..6de3eb8 100755 --- a/codes/105.py +++ b/codes/105.py @@ -1 +1,3 @@ -print "Hello,World" +#!/usr/bin/env python +# -*- coding:utf-8 -*- +print('Hello World') diff --git a/codes/217.py b/codes/217.py index 564f238..3aacce4 100755 --- a/codes/217.py +++ b/codes/217.py @@ -24,8 +24,8 @@ def author(self, address): info = Person("qiwsir",lang="python",website="qiwsir.github.io") #print "laoqi.name=",laoqi.name -print "Author name from laoqi:",laoqi.author("China") -print "Author name from info:",info.author("Suzhou") +print("Author name from laoqi:",laoqi.author("China")) +print("Author name from info:",info.author("Suzhou")) #print "info.name=",info.name #print "-------" #print "laoqi.lang=",laoqi.lang diff --git a/codes/220-2.py b/codes/220-2.py index abf1787..cddb85b 100755 --- a/codes/220-2.py +++ b/codes/220-2.py @@ -3,19 +3,19 @@ class A: def __init__(self): - print "aaa" + print("aaa") def amethod(self): - print "method a" + print("method a") class B(A): def __init__(self): - print "bbb" + print("bbb") if __name__=="__main__": - print "A--->" + print("A--->") a = A() a.amethod() - print "B--->" + print("B--->") b = B() b.amethod() diff --git a/codes/220.py b/codes/220.py index efd8b38..da639ee 100755 --- a/codes/220.py +++ b/codes/220.py @@ -19,8 +19,8 @@ def __init__(self,name,email): if __name__=="__main__": writer = Pythoner("qiwsir","qiwsir@gmail.com") - print "name=",writer.name - print "lang=",writer.lang - print "email=",writer.email - print "system=",writer.system - print "website=",writer.website + print("name=",writer.name) + print("lang=",writer.lang) + print("email=",writer.email) + print("system=",writer.system) + print("website=",writer.website) diff --git a/codes/221.py b/codes/221.py index ea8492c..770f3d3 100755 --- a/codes/221.py +++ b/codes/221.py @@ -5,11 +5,11 @@ def outer_foo(): a = 10 def inner_foo(): a = 20 - print "inner_foo,a=",a + print("inner_foo,a=",a) inner_foo() - print "outer_foo,a=",a + print("outer_foo,a=",a) a = 30 outer_foo() -print "a=",a +print("a=",a) diff --git a/codes/225.py b/codes/225.py index ed8bc17..26f39ce 100755 --- a/codes/225.py +++ b/codes/225.py @@ -4,10 +4,10 @@ class Person: def __init__(self,name): self.name = name - print self.name + print(self.name) def __work(self,salary): - print "%s salary is: %d"%(self.name,salary) + print("%s salary is: %d"%(self.name,salary)) def worker(self): self.__work(500)