你好,我是 Django 的新手,
我正在使用 django 创建一个身份验证系统。
用户登录后,我会将值存储在会话中。
user = authenticate(username=username, password=password)
request.session['mid'] = user.id
Run Code Online (Sandbox Code Playgroud)
当我刷新时,我可以收到会话 ID
uid = request.session['mid']
Run Code Online (Sandbox Code Playgroud)
但我不确定如何从用户 ID 中获取用户数据。谁能告诉我如何使用用户 ID 获取用户对象。
我有一个数组:
Array
(
[0] => dir0|file0.txt
[1] => dir0|file1.txt
[2] => dir1|file2.txt
[3] => dir1|filea.txt
[4] => dir2|fileb.txt
)
Run Code Online (Sandbox Code Playgroud)
我希望它显示为树,例如:
dir0
file0.txt
file1.txt
dir1
file2.txt
filea.txt
dir2
fileb.txt
Run Code Online (Sandbox Code Playgroud)
谁能解释我怎么能这样做?
编辑:已更新为多维数组:
$paths[0][0] = 'dir0|file0.txt';
$paths[0][1] = 400;
$paths[1][0] = 'dir0|filea.txt';
$paths[1][1] = 500;
$paths[2][0] = 'dir1|file1.txt';
$paths[2][1] = 600;
$paths[3][0] = 'dir1|fileb.txt';
$paths[3][1] = 700;
$paths[4][0] = 'dir2|filec.txt';
$paths[4][1] = 700;
Run Code Online (Sandbox Code Playgroud)
我希望输出为:
dir0 (900)
file0.txt (400)
filea.txt (500)
dir1 (1300)
file1.txt(600)
fileb.txt (700)
dir2 (700)
filec.txt (700)
Run Code Online (Sandbox Code Playgroud)
需要添加值并以root身份显示.
我们可以使用zkoss或vaadin框架创建桌面应用程序吗?
如果是这样,请解释如何使用一些示例创建它.
我试图从
http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
中举例说明BufferReader未关闭是否需要关闭BufferReader或不关闭?请解释.
FileInputStream fstream = new FileInputStream("textfile.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
Run Code Online (Sandbox Code Playgroud) 我试图检查字符指针是否为空.如何检查值是否为null我基本上是从java
char* mypath = getenv("MYPATH");
if(!mypath) //this is not working
throw "path not found";
if(mypath == NULL) //this is also not working
throw "path not found";
Run Code Online (Sandbox Code Playgroud)
我得到一个例外"在抛出'char const*'的实例后调用终止"
我试图在Node.js中使用node-rest-client REST客户端.
当我使用以下代码时,它会返回,null但控制台会在此之后打印响应.如何使用REST客户端进行同步调用?
var postRequest = function(url, args) {
var client = new Client();
var responseData = {};
client.post(url, args, function(data, response) {
responseData = data;
console.log(responseData);
});
return responseData;
};
Run Code Online (Sandbox Code Playgroud) 我正在尝试替换 url 中的 \u。
C:\testing\bing\utest\university.txt
当我使用时,url=url.replaceAll("\\u", "\\\\u");我收到以下错误我是否知道如何用 \u 替换 \u 或转义 \u
java.util.regex.PatternSyntaxException: Illegal Unicode escape sequence near index 2
\u
Run Code Online (Sandbox Code Playgroud) 我需要将字符串转换为以下格式.
1000 -> 0000001000
10000 -> 0000010000
25000 -> 0000025000
Run Code Online (Sandbox Code Playgroud)
我试过这种方式 ceil(str_pad($range_array[0],6 , "0", STR_PAD_LEFT))
但这适用于1000,但失败了10,000.
有没有创建它的功能?