我正在我的学校项目中进行注册,其中一部分是关于注册。我必须以
的形式输入客户端所以他可以注册并附加到txt文件中,
但我还必须使“用户名”成为文件中的唯一(因为我也会有其他的cilents)和“密码”超过6个字符并拥有至少一个数字。
Btw角色意味着他是买家。加粗的部分我没有做,如果可能我需要帮助。感谢
def reg()
f = open("svi.txt","a")
username = input("Username: ")
password = input("Password: ")
name = input("Name of a client: ")
lastname = input("Lastname of a client: ")
print()
print("Successful registration! ")
print()
cilent = username + "|" + password + "|" + name + "|" + lastname + "|" + "buyer"
print(cilent,file = f)
f.close()
答案 0 :(得分:0)
您需要添加一些文件解析和逻辑才能完成此任务。你的工作是:
1:搜索现有文件以查看用户名是否已存在。通过您提供的格式,您需要搜索每一行到第一个' |'并查看新用户是否具有唯一名称:
$total
2:查看密码是否符合条件:
<div class="total_cmd">
{{ number_format($total/100, 2, '.', ' ') }} €
</div>
3:仅当用户名是唯一且密码符合您的条件时才写新行:
avgCreditUsage('[1, 72]-[2, 79]-[3, 81]-[4, 76]-[5, 93]-[6, 81]-[7, 85]-[8, 66]-[9, 66]-[10, 72]-[11, 67]-[12, 72]-[13, 71]-[14, 80]-[15, 94]-[16, 56]-[17, 61]-[18, 81]-[19, 82]-[20, 64]-[21, 74]-[22, 77]-[23, 96]-[24, 83]-[25, 91]-[26, 85]-[27, 72]-[28, 80]-[29, 74]-[30, 70]-[31, 86]');
function avgCreditUsage(creditsPerDOM) {
/*
* LINE CHART
* ----------
*/
//var sin = [
// [gd(2012, 0, 1), 1652.21], [gd(2012, 1, 1), 1742.14], [gd(2012, 2, 1), 1673.77], [gd(2012, 3, 1), 1649.69],
// [gd(2012, 4, 1), 1591.19], [gd(2012, 5, 1), 1598.76], [gd(2012, 6, 1), 1589.90], [gd(2012, 7, 1), 1630.31],
// [gd(2012, 8, 1), 1744.81], [gd(2012, 9, 1), 1746.58], [gd(2012, 10, 1), 1721.64], [gd(2012, 11, 2), 1684.76]
// ]
var array = creditsPerDOM.split("-");
var sin = [array];
var line_data1 = {
data: sin,
color: "#00c0ef"
};
$.plot("#line-chart", [line_data1], {
grid: {
hoverable: true,
borderColor: "#f3f3f3",
borderWidth: 1,
tickColor: "#f3f3f3"
},
series: {
shadowSize: 0,
lines: {
show: true
},
points: {
show: true
}
},
lines: {
fill: false,
color: ["#3c8dbc", "#f56954"]
},
yaxis: {
show: true,
},
xaxis: {
show: true
}
});
//Initialize tooltip on hover
$('<div class="tooltip-inner" id="line-chart-tooltip"></div>').css({
position: "absolute",
display: "none",
opacity: 0.8
}).appendTo("body");
$("#line-chart").bind("plothover", function (event, pos, item) {
if (item) {
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
$("#line-chart-tooltip").html(item.series.label + " of " + x + " = " + y)
.css({ top: item.pageY + 5, left: item.pageX + 5 })
.fadeIn(200);
} else {
$("#line-chart-tooltip").hide();
}
});
/* END LINE CHART */
}
编辑:您可能还需要在读写模式下打开它,例如&#34; a +&#34;而不是&#34; a&#34;。