我试图通过BorderSide更改我的TextField边框的颜色,但它不起作用.
这是我的代码.
new TextField(
decoration: new InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(color: Colors.teal)
),
hintText: 'Tell us about yourself',
helperText: 'Keep it short, this is just a demo.',
labelText: 'Life story',
prefixIcon: const Icon(Icons.person, color: Colors.green,),
prefixText: ' ',
suffixText: 'USD',
suffixStyle: const TextStyle(color: Colors.green)),
)
)
Run Code Online (Sandbox Code Playgroud)
我指的是由tensorflow给出的Deep MNIST for Experts教程.我在培训和评估该教程的一部分时遇到了问题.他们在那里给出了如下示例代码.
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv),reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.initialize_all_variables())
for i in range(20000):
batch = mnist.train.next_batch(50)
if i%100 == 0:
train_accuracy = accuracy.eval(feed_dict={x:batch[0], y_: batch[1], keep_prob: 1.0})
print("step %d, training accuracy %g"%(i, train_accuracy))
train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
print("test accuracy %g"%accuracy.eval(feed_dict={x: mnist.test.images,
y_: mnist.test.labels, keep_prob: 1.0}))
Run Code Online (Sandbox Code Playgroud)
所以在这些代码段中他们曾经一次使用accuracy.eval()过.还有其他时间train_step.run().据我所知,它们都是张量变量.
在某些情况下,我看到过
sess.run(variable, feed_dict)
Run Code Online (Sandbox Code Playgroud)
所以我的问题是这三种实现之间有什么区别.我怎么知道什么时候用...?
谢谢!!
#include <iostream>
struct person_t{
int age;
};
person_t get_person1(){
person_t person;
person.age = 10;
return person;
}
person_t * get_person2(){
person_t *person = new person_t;
person->age = 20;
return person;
}
int main(){
person_t person1 = get_person1();
person_t *person2 = get_person2();
std::cout << person1.age << std::endl;
std::cout << person2->age << std::endl;
delete person2;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想知道从函数返回结构的最安全的方法是什么.
正如在这里和这里的问题的答案中所说,当你创建一个对象时get_person1(),该对象将在它超出范围之后被销毁.
但是当我搜索"如何从函数c ++返回一个结构"时,它建议我使用方法一(带有get_person1())(这里的例子).但我认为该方法会在调用函数后销毁对象,我认为方法2是最安全的.
我错了吗?或者关于这个话题的任何意见..?
谢谢!!
我正在尝试使用HttpClient对象连接到网站.它适用于我们通常使用的网站(如谷歌).但是有一个网站,当我尝试连接时,我的程序给出了这个错误..
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1369)
....................
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
...............
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 27 more
Run Code Online (Sandbox Code Playgroud)
当我尝试从浏览器转到此URL时,我必须单击继续.否则浏览器将无法加载页面.它给出了一个 …
感谢您的关注.
我创建了一个程序,我正在使用登录表单和注册表单.一旦用户注册他们的电子邮件,他们的密码将被保存到submit.txt.然后他们将返回登录表单并输入保存到的电子邮件和密码submit.txt.
在我的代码中,我使用Register文件的写文件和Login Form的Read文件.但是,它不起作用.我在用于读取文件的代码中知道我的问题.你可以帮我实现吗?
非常感谢你的帮助.
if (checkPassword(usern, hash)) {
System.out.println("Logged in!");
ChooseWindow ptb = new ChooseWindow();
ptb.setVisible(true);
LoginWindow.this.dispose();
} else {
System.out.println("Wrong password");
}
public boolean checkPassword(String username, String pass) {
try {
FileReader inFile = new FileReader("/users/Ender/Desktop/GetUser/submit.txt");
BufferedReader inStream = new BufferedReader(inFile);
String inString;
while ((inString = inStream.readLine()) != null) {}
inStream.close();
}catch (IOException e) {
e.printStackTrace();
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我是Android开发的新手,我在一个关于自定义的网站的示例的帮助下编写了一些代码ListView,现在ListView我希望附加一个EditText过滤文本并显示在ListView我写的内容中.
目前,当我输入任何内容时,ListView空白并且没有显示,但是当我删除输入时,ListView恢复原始项目.
这是我的适配器类:
public class EntryAdapter extends ArrayAdapter<Item> {
private Context context;
private ArrayList<Item> items;
private LayoutInflater vi;
public Context conx;
public EntryAdapter(Context context, ArrayList<Item> items) {
super(context,0, items);
this.context = context;
this.items = items;
vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
Run Code Online (Sandbox Code Playgroud)
这是我为此插入的数据 main-class
items.add(new SectionItem("letters"));
items.add(new EntryItem("a","subtitle","image"));
items.add(new EntryItem("b","subtitle","image"));
Run Code Online (Sandbox Code Playgroud)
这是我的textWatcher,我创建的一个简单的:
inputSearch = (EditText) findViewById(R.id.inputSearch);
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) …Run Code Online (Sandbox Code Playgroud) 是否有一种方式来获得的类名dart class作为一个String或一个Type物体..?
class MyClass {
}
var myClass = MyClass();
Run Code Online (Sandbox Code Playgroud)
我知道property,runtimeType它将返回对象的类型作为Type对象。但是类有类似的功能吗?
print(myClass.runtimeType.toString());
Run Code Online (Sandbox Code Playgroud)
我目前正在做的是创建一个类的对象并使用它runtimeType。
String type = MyClass().runtimeType.toString();
Run Code Online (Sandbox Code Playgroud)
注意:在每个类中都有python一个变量__name__,它可以满足我的需要。
我的最终目标是使用以前保存的类名称创建dart对象。在本期中,他们提出了一种使用Maps 的方法。
问题是我有很多类,在我的情况下该方法看起来很混乱。
我目前要做的是通过以下方式保存对象类型:
var saving = myClass.runtimeType.toString();
Run Code Online (Sandbox Code Playgroud)
并且在加载时:
if (saving == MyClass().runtimeType.toString()) {
return MyClass();
}
Run Code Online (Sandbox Code Playgroud)
根据您的经验和意见,您可以提出更好的解决方案吗?
谢谢!!!
我有以下函数将int?通过接受返回String。
int? convert(String s) {
// Some implementation
}
Run Code Online (Sandbox Code Playgroud)
然后我有这个函数可以将 a 转换Stream<String>为Stream<int>. 我当前的实现如下所示。
Stream<int> convertStream(Stream<String> s) {
return s
.map<int?>((i) => convert(i))
.where((i) => i!=null)
.map<int>((i) => i!);
}
Run Code Online (Sandbox Code Playgroud)
这种方式对我来说并不好看。有没有其他方法可以用来实现相同的行为?
我有关于的内核大小的问题morphologyEx。我有一些验证码图片,我想对它们执行相同的操作并获得相同的最终结果。
代码:
image = cv2.imread("Image.jpg")
gray = cv2.cvtColor(image , cv2.COLOR_BGR2GRAY)
ret, thresh1 = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
k1 = np.ones((3,3))
k2 = np.ones((5,5))
bottom_image = cv2.morphologyEx(thresh1, cv2.MORPH_CLOSE, k1)
bottom_image = 255-bottom_image
bottom_image = remove_boxes(bottom_image , True)
ret,thresh2 = cv2.threshold(bottom_image,127,255,cv2.THRESH_BINARY_INV)
opening = cv2.morphologyEx(thresh2, cv2.MORPH_OPEN, k1)
#closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, k)
# cv2.imshow('opening', opening)
dilate = cv2.morphologyEx(opening, cv2.MORPH_DILATE, k2)
dilate = cv2.bitwise_not(dilate)
# cv2.imshow('dilation', dilate)
bottom_image = cv2.morphologyEx(bottom_image, cv2.MORPH_CLOSE, k1)
Run Code Online (Sandbox Code Playgroud)
完美的结果是
但是,当我将其应用于具有相同结构输出的其他图像时,就会出现问题。
输入: …
这是我第一次使用Android工作室,我不知道这些错误意味着什么,或者他们在这里暗示图像描述
[渲染问题无法加载具有未知错误的AppCompat ActionBar.ConstraintLayout中缺少约束
此视图不受约束.它只有设计时位置,因此它会在运行时跳转到(0,0),除非您添加约束布局编辑器允许您将小部件放在画布上的任何位置,并使用设计时属性(例如layout_editor_absoluteX)记录当前位置.这些属性不会在运行时应用,因此如果在设备上推送布局,则窗口小部件可能显示在与编辑器中显示的位置不同的位置.要解决此问题,请通过从边连接拖动来确保窗口小部件具有水平和垂直约束.
dart ×3
java ×3
android ×2
flutter ×2
python ×2
c++ ×1
filereader ×1
function ×1
httpclient ×1
listview ×1
opencv ×1
python-2.7 ×1
readfile ×1
return ×1
struct ×1
swing ×1
tensorflow ×1