只是为学校制作一个程序,我一直在“set intRnumber”部分得到一个无效的语法。有人可以帮忙吗?
StrName = ""
StrLevel = ""
intRnumber = 0
StrName = input("What's your name? ")
print("Hello,", StrName)
StrLevel = input("Would you like a low, medium, or high random number? ")
if StrLevel == "low":
set intRnumber == "5"
elif StrLevel == "medium":
set intRnumber == "50"
elif StrLevel == "high":
set intRnumber == "500"
else:
print("Invalid input, please input low, medium, or high!")
答案 0 :(得分:0)
在python中,你没有像你想要的那样执行assignment。
你需要这样做:
set variable == value
而不是
StrLevel = input("Would you like a low, medium, or high random number? ")
if StrLevel == "low":
intRnumber = "5"
elif StrLevel == "medium":
intRnumber = "50"
elif StrLevel == "high":
intRnumber = "500"
else:
print("Invalid input, please input low, medium, or high!")
您在代码的前几行中拥有它,但代码的最后一部分需要更改为:
public partial class UsersViewModel : INotifyPropertyChanged
{
public RelayCommand<UserViewModel> editButton_Click_Command { get; set; }
public UsersViewModel()
{
editButton_Click_Command = new RelayCommand<UserViewModel>(OneditButton_Click_Command);
this.Users = new ObservableCollection<UserViewModel>();
this.Users.Add(new UserViewModel() { FirstName = "John", LastName = "Doe", EMail = "JohnDoe@yahoo.com", EndDate = new DateTime(2016,2,1), Position = "Developer", UserID = 0 });
}
private ObservableCollection<UserViewModel> _Users;
public ObservableCollection<UserViewModel> Users
{
get { return _Users; }
set { _Users = value; NotifyPropertyChanged("Users"); }
}
private void OneditButton_Click_Command(UserViewModel obj)
{
//Parameter object is always NULL here!!!
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}