程序设计

专业和发烧友程序员的问答





7
在Python中提取一部分文件路径(目录)
我需要提取某个路径的父目录的名称。看起来是这样的: c:\stuff\directory_i_need\subdir\file 我正在使用使用文件directory_i_need名(而不是路径)的东西来修改“文件”的内容。我创建了一个函数,该函数会给我所有文件的列表,然后... for path in file_list: #directory_name = os.path.dirname(path) # this is not what I need, that's why it is commented directories, files = path.split('\\') line_replace_add_directory = line_replace + directories # this is what I want to add in the text, with the directory name at the end # …




8
将值附加到查询字符串
我设置的URL与列表中的URL类似 http://somesite.com/backup/lol.php?id=1&server=4&location=us http://somesite.com/news.php?article=1&lang=zh-CN 我设法使用以下代码获取查询字符串: myurl = longurl.Split('?'); NameValueCollection qs = HttpUtility.ParseQueryString(myurl [1]); foreach (string lol in qs) { // results will return } 但是它仅基于提供的URL 返回诸如id,server,location等参数 。 我需要为现有查询字符串添加/附加值。 例如,URL: http://somesite.com/backup/index.php?action=login&attempts=1 我需要更改查询字符串参数的值: 行动=登录1 尝试次数= 11 如您所见,我为每个值附加了“ 1”。我需要从其中具有不同查询字符串的字符串中获取一组URL,然后在每个参数的末尾添加一个值,然后再次将它们添加到列表中。


2
打字稿中的Array <Type> VS Type []
据我所知,当属性为数组时,可以通过两种方式定义属性的类型。 property_name: type 类型可以是 Array&lt;string&gt;, Array&lt;MyType&gt;, etc. (e.g. let prop1: Array&lt;string&gt;) 和 string[], MyType[], etc. (e.g. let prop1: string[]) 有什么区别两种情况之间?还是我误会了某些东西(例如有关&lt;&gt;的某些信息?) 编辑,因为该问题被标记为重复,我知道还有另一个关于any []的问题,但是我仍然在发布之前先看了一下,对我来说,它更多地是关于'any'类型而不是不同的[] VS &lt; &gt;我问
162 typescript 

11
Bootstrap 4中心垂直和水平对齐
我有一个页面,其中仅存在表单,并且我希望将表单放置在屏幕的中央。 &lt;div class="container"&gt; &lt;div class="row justify-content-center align-items-center"&gt; &lt;form&gt; &lt;div class="form-group"&gt; &lt;label for="formGroupExampleInput"&gt;Example label&lt;/label&gt; &lt;input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input"&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="formGroupExampleInput2"&gt;Another label&lt;/label&gt; &lt;input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; 该justify-content-center对齐表格水平,但我无法弄清楚如何垂直对齐。我已经尝试使用align-items-center和align-self-center,但是它不起作用。 我想念什么? 演示


13
Jupyter Notebook无法保存:帖子中缺少“ _xsrf”参数
我已经在jupyter笔记本上运行了大约26个小时的脚本;我还没有真正将计算机用于其他用途,但是它需要运行此程序,该程序大约需要30个小时才能完成。大约21个小时后,它停止保存了,我的终端有了这个: 403 PUT /api/contents/[file.ipynb] (::1): '_xsrf' argument missing from POST 其中[file.ipynb]是我的jupyter笔记本的位置。它还说: '_xsrf' argument missing from post 再次在笔记本的右上角。该程序仍在运行,并且我不想重新启动jupyter Notebook并且不得不再次运行该程序,因为我有最后期限,我还能做点什么? 我使用的是谷歌浏览器,但我的代码中没有LastPass扩展名或任何'%'字符,如另一篇文章所建议的那样。 谢谢你的帮助!

20
错误ITMS-包中找到90167号应用程序捆绑包
在开始撰写错误之前,我正在macOS Sierra上运行,并使用Xcode 7.3.1。 因此,我正在从我的应用程序创建一个存档,我对该应用程序进行了验证并通过了验证,但是当上载到App Store时,出现错误“ ERROR ITMS-90167 No. app bundles package in package”。 我已经检查了所有文档并拥有所有内容。 我有所有的配置文件。 我已经发布了“ iOS发行版”。 在安装macOS Sierra之后,此错误才开始出现。 有人知道为什么我会收到此错误吗? 提前致谢。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.