我需要从我在字符串中获得的文件名来决定文件的文件类型.所以我决定获取String的最后三个字符来决定它是什么文件类型.如何获取String中的最后三个字符.例如
var fileName = "test.pdf"
Run Code Online (Sandbox Code Playgroud)
我需要单独获取pdf.有没有其他更好的方法来检查除此之外的文件类型.请建议我.因为我认为,我能够识别文件类型是否有四个字符,如"jpeg"和其他东西.提前致谢.
@IBAction func operate(sender: UIButton) {
if let operation = sender.currentTitle {
if let result = brain.performOperation(operation) {
displayValue = result
}
else {
displayValue = 0.0
}
}
}
Run Code Online (Sandbox Code Playgroud)
我是编码的新手,所以请原谅我的编码格式和其他不一致之处.我一直在试用iOS 8介绍斯坦福大学教授的快速编程,我遇到了修改后的计算器问题.
我得到三个错误.第一个是快速编译警告 - 在
if let result = brain.performOperation(operation)
Run Code Online (Sandbox Code Playgroud)
它说
常量'result'推断为type()可能是意外的.
它给了我这样做的建议----
if let result: () = brain.performOperation(operation)
Run Code Online (Sandbox Code Playgroud)
另外两个错误是
如果让结果行,条件绑定中的绑定值必须是可选类型
无法在"displayValue = result"处将type()的值赋值为Double
如果有人需要有关代码的更多信息,这是github链接.
提前致谢.
我目前得到错误
ImportError:无法导入名称gof
当导入theano时.
>>> import theano
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import theano
File "C:\Python27\lib\site-packages\theano\__init__.py", line 63, in <module>
from theano.compile import (
File "C:\Python27\lib\site-packages\theano\compile\__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "C:\Python27\lib\site-packages\theano\compile\function_module.py", line 16, in <module>
from theano import gof
ImportError: cannot import name gof
Run Code Online (Sandbox Code Playgroud)
我正在使用python 2.7.10().Theano安装使用pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git.希望能得到你解决这个问题的建议
我将一些付款值存储在一个活动中
SharedPreferences spreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
productId = spreferences.getString("productId", "");
purchaseToken = spreferences.getString("purchaseToken", "");
orderId = spreferences.getString("orderId", "");
Run Code Online (Sandbox Code Playgroud)
现在我在另一个中检索它们
SharedPreferences spreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
productId = spreferences.getString("productId", "");
purchaseToken = spreferences.getString("purchaseToken", "");
orderId = spreferences.getString("orderId", "");
Run Code Online (Sandbox Code Playgroud)
我的问题是在检索它们后在第二个Activity中删除它们.谢谢.
在这里,我必须#second_area在点击输入时隐藏div id .ID名称是 #employee_id
<form id="search_form" name="search_form" method="get" action="" >
<table width="98%" id="performance_tbl" align="center">
<div id="first_row">
<tr class="first_tr">
<th scope="row"><label for="employee_id">Employee ID: </label></th>
<td><input type="text" name="employee_id" id="employee_id" /></td>
</tr>
</div>
<tr>
<td> </td>
</tr>
<div id="second_area">
<tr>
<th scope="row"><label for="company_id">Company Name:</label></th>
<td><input type="text" name="company_id" id="company_id" /></td>
<th><label for="department_id">Department Name: </label></th>
<td><input type="text" name="department_id" id="department_id" /></td>
</tr>
<tr>
<th scope="row"><label for="current_year">Select Year: </label></th>
<td><input type="number" name="current_year" id="current_year" /></td>
<th><label for="compare_year">Compare Year: </label></th>
<td><input type="number" name="compare_year" id="compare_year" /></td>
</tr>
<tr>
<th …Run Code Online (Sandbox Code Playgroud) 我正在阅读有关mapreduce的内容,我想知道一个特定的场景.假设我们有几个文件(例如fileA,fileB,fileC),每个文件由多个整数组成.如果我们想对所有文件中的数字进行排序以创建如下内容:
23 fileA
34 fileB
35 fileA
60 fileA
60 fileC
Run Code Online (Sandbox Code Playgroud)
地图和减少过程如何工作?
目前,这就是我所拥有的,但它并不完全正确;
(fileName, fileContent) -> (map to) (Number, fileName)
对临时密钥,值对和get进行排序
(Number, (list of){fileName1, fileName2...})
减少临时对并得到
(Number, fileName1)
(Number, fileName2)
Run Code Online (Sandbox Code Playgroud)
等等
问题是在排序阶段,文件名可能不是按字母顺序排列,因此reduce部分不会生成正确的输出.有人可以就这种情况的正确方法提供一些见解吗?
我使用过雅虎的符号查找
它以JSON格式返回数据.喜欢以下
YAHOO.Finance.SymbolSuggest.ssCallback(
{
"ResultSet": {
"Query": "ya",
"Result": [
{
"symbol": "YHOO",
"name": "Yahoo! Inc.",
"exch": "NMS",
"type": "S",
"exchDisp": "NASDAQ"
},
{
"symbol": "AUY",
"name": "Yamana Gold, Inc.",
"exch": "NYQ",
"type": "S",
"exchDisp": "NYSE"
},
{
"symbol": "YZC",
"name": "Yanzhou Coal Mining Co. Ltd.",
"exch": "NYQ",
"type": "S",
"exchDisp": "NYSE"
},
{
"symbol": "YRI.TO",
"name": "YAMANA GOLD INC COM NPV",
"exch": "TOR",
"type": "S",
"exchDisp": "Toronto"
},
{
"symbol": "8046.TW",
"name": "NAN YA PRINTED CIR TWD10",
"exch": …Run Code Online (Sandbox Code Playgroud) 我想datetime使用 Microsoft Webmatrix 3 中的 SQL Server Compact Edition 将值插入数据库。
我尝试了以下查询:
INSERT INTO Tutorials ([Tutorial], [StartDate])
VALUES ('3d', CONVERT(DATETIME, '07-23-08', 110));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
不支持转换。[要转换的类型(如果已知)= datetime,要转换的类型(如果已知)= float ]
我在flexbox中使用box-sizing: border-box;不同的border厚度.我希望flexbox中的元素具有相等的宽度,但它计算width没有边框的元素.
这是一个例子:width我的容器是100px,所以每个元素应该是20px; 但它们是19.2px(x4)和23.2px.
.container {
display: flex;
flex-direction: row;
align-items: center;
width: 100px;
}
.container .block {
height: 28px;
flex: 1;
border: 1px solid black;
box-sizing: border-box;
}
.container .block.selected {
border: 3px solid blue;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<span class="block">0</span>
<span class="block">1</span>
<span class="block selected">2</span>
<span class="block">3</span>
<span class="block">4</span>
</div>Run Code Online (Sandbox Code Playgroud)
我正在尝试为网站定位一些图像,并且我给了这些图像不同的 ID,因此我可以以不同的方式定位它们。在我的CSS上,当我开始定位时它不起作用。通过 ID 或类别,
我将这些图像放置在 div 中只是为了检查一切是否正常,并且我想可以轻松指向我想要使用的确切 img 标签。
代码如下:
<--html-->
<div class="resume">
<a href="#"><img style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/pdf.png" class="pdf" ></a>
<a href="#"><img id="word" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/mword.png" ></a>
<img id="pline" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/line1.png" >
<img id="wline" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/line2.png" >
</div>
Run Code Online (Sandbox Code Playgroud)
<--css-->
.resume img
{
position:relative;
top:100px;
}
.resume img .pdf
{
position: relative;
top:500px;
}
Run Code Online (Sandbox Code Playgroud)
因此,如果有人能帮助我解决我出错的地方,我将不胜感激。谢谢!
什么是一个简单的方法来减少像AAA:111;BBB:222;333;444;CCC:555Swift中的字典一样的字符串.我有以下代码:
var str = "AAA:111;BBB:222;333;444;CCC:555"
var astr = str.componentsSeparatedByString(";").map { (element) -> [String:String] in
var elements = element.componentsSeparatedByString(":")
if elements.count < 2 {
elements.insert("N/A", atIndex: 0)
}
return [elements[0]:elements[1]]
}
Run Code Online (Sandbox Code Playgroud)
上面的代码产生一个阵列的字典:
[["A": "111"], ["BBB": "222"], ["UKW": "333"], ["UKW": "444"], ["CCC": "555"]]
我希望它能产生,
["A": "111", "BBB": "222", "UKW": "333", "UKW": "444", "CCC": "555"]
但是没有我尝试的东西,因为我map在一个数组上调用函数似乎不可能转换map函数结果的性质.
注意:字符串格式的字典被描述为具有KEY:VALUE;格式或VALUE;格式,在这种情况下,映射函数将添加"N/A"as作为未命名值的键.
非常感谢任何有关此事的帮助.
我需要用列表的内容制作一些列表.像一个:
list=["One", "Two", " Three "]
for x in list:
x = []
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为如果我这样做:
list(One)
Run Code Online (Sandbox Code Playgroud)
它没有显示One的内容,因为One没有定义.
那么,是否可以创建包含其他列表内容的列表?