Python練習例87
問題:回答結果(構造体変数の受け渡し)。
プログラム分析:なし。
プログラムソースコード:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
class student:
x = 0
c = 0
def f(stu):
stu.x = 20
stu.c = 'c'
a= student()
a.x = 3
a.c = 'a'
f(a)
print a.x,a.c
上記の例の出力結果は次のとおりです:
20 cその他の拡張