我将我的工作区从C9.io迁移到Codeanywhere,在C9.io上我的脚本运行正常;我的脚本是我一直在努力的python终端游戏/应用程序。我有一个测试脚本来运行我到目前为止创建的函数,以及用于创建不同类和播放器对象的player.py文件,具有保存,加载等功能。在C9.io上,这是输出。
public class Values
{
public List<object> DayOfMonth { get; set; }
public List<object> Month { get; set; }
public List<object> DaysOfWeek { get; set; }
[Required(ErrorMessage = "Enter a number between 0-59!")]
[RegularExpression(@"^(,{0,1}(\b\d\b|[0-5][0-9]|\*+)(-\b\d\b|-[0-5][0-9]){0,1})$", ErrorMessage = "Enter a number between 0-59!")]
public object Second { get; set; }
[Required(ErrorMessage = "Enter a number between 0-59!")]
[RegularExpression(@"^(,{0,1}(\b\d\b|[0-5][0-9]|\*+)(-\b\d\b|-[0-5][0-9]){0,1})$", ErrorMessage = "Enter a number between 0-59!")]
public object Minute { get; set; }
[Required(ErrorMessage = "Enter a number between 0-23!")]
[RegularExpression(@"^(,{0,1}(\b\d\b|[0-1][0-9]|[2][0-3]|\*+)(-\b\d\b|-[0-1][0-9]|-[2][0-4]){0,1})$", ErrorMessage = "Enter a number between 0-23!")]
public object Hour { get; set; }
//public List<SelectListItem> Jobs { get; set; }
public int Job { get; set; }
public List<Values> DofMInfo { get; set; }
public string DofMNo { get; set; }
public int DofMID { get; set; }
public List<Values> MonthInfo { get; set; }
public int monthID { get; set; }
public string monthName { get; set; }
public List<Values> DayInfo { get; set; }
public int dayID { get; set; }
public string dayName { get; set; }
[Required(ErrorMessage ="Enter the number of repeat times. 0 = execute once!")]
public int repeatTime { get; set; }
public bool IsChecked { get; set; }
}
但是当我在Codeanywhere上运行测试脚本时,就会发生这种情况。
Strength: 15
Agility: 10
Critical Chance: 25
Spell Power: 15
Intellect: 5
Speed: 5
---
Health: 100/100
Stamina: 10
Armor: 20
Resilience: 2
---
Strength: 20.25
Agility: 10
Critical Chance: 43.75
Spell Power: 15
Intellect: 5
Speed: 4.0
---
Health: 100/100
Stamina: 7.5
Armor: 16.0
Resilience: 1.4
---
# more test info regarding other scripts
我尝试将Strength: 15
Strength: 15
Agility: 10
Critical Chance: 25
Spell Power: 15
Intellect: 5
Speed: 5
---
Health: 100/100
Stamina: 10
Armor: 20
Resilience: 2
---
Traceback (most recent call last):
File "test.py", line 7, in <module>
player2 = BerserkerCharacter('Jon', 'Snow')
File "/home/cabox/workspace/grimside/assets/player.py", line 93, in __init__
super().__init__()
TypeError: super() takes at least 1 argument (0 given)
放在self
的前面,并在论证中抛出super().__init__()
,而且我不熟悉Python,所以我不知道要解决的问题。这是我的剧本。
test.py
self
player.py
from assets import *
player = BaseCharacter()
player.show_player_stats("offensive")
print('---')
player.show_player_stats("defensive")
print('---')
player2 = BerserkerCharacter('Jon', 'Snow')
player2.show_player_stats("offensive")
print('---')
player2.show_player_stats("defensive")
print('---')
#more test info regarding other scripts
答案 0 :(得分:1)
根据评论中的讨论:
事实证明,容器(错误地)默认运行Python 2.7,而不是如说明中所述的3.4。
最简单的解决方法是通过指定参数使super
的调用对两个版本都有效,例如:
class WarriorCharacter(BaseCharacter):
#define data when initialized, or the Object is created
def __init__(self, first_name, last_name):
super(WarriorCharacter, self).__init__()
和
class BerserkerCharacter(BaseCharacter):
def __init__(self, first_name, last_name):
super(BerserkerCharacter, self).__init__()