我正在尝试为我正在构建的.Net Web应用程序设置应用程序基本路径.我一直在配置构建器上遇到错误.这是我得到的错误.
DNX,Version=v4.5.1 error CS1061: 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' and no extension method 'SetBasePath' accepting a first argument of type 'ConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)
我假设我会得到同样的错误我.AddJsonFile()和.AddEnvironmentVariables().我做错什么了吗?我没有为project.json添加正确的依赖项吗?我附上了我的startup.cs和我的project.json.
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "TripPlanner"
},
"dependencies": {
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration": "1.0.0-beta8",
"Microsoft.Framework.DependencyInjection": "1.0.0-beta8"
//"Microsoft.Extensions.PlatformAbstractions": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": …Run Code Online (Sandbox Code Playgroud) 所以我试图让我的python程序接受用户的文件,然后截断文件,向其添加内容,输出文件,最后关闭.问题是它不会输出.我已经在写入+读取模式下打开文件,但文件不会输出target.read().这是我的源代码.问题是从底部开始的第三行.
from sys import argv
script, filename = argv
print "We're going to erase %r." %filename
print "If you don't want that, hit CTRL-C."
print "If you do want that, hit RETURN."
raw_input("?")
print "Opening the file..."
target = open(filename, 'w+r')
print "Truncating the file. Good bye!"
target.truncate()
print "Now I'm going to ask you for three lines."
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")
print "I'm going to write …Run Code Online (Sandbox Code Playgroud)